#include <stdio.h>
#include <string.h>


int lengthOfLongestSubstring(char* s)
{
    int max = 0;
    int dup = 0;
    int nums[128] = {0};
    for(int i = 0;i < strlen(s);i++)
    {
        dup = dup > nums[s[i]] ? dup : nums[s[i]];
        nums[s[i]] = i + 1;
        max = max > (i - dup + 1) ? max :  (i - dup + 1);
    }

    return max;
}

int main()
{
    char s[] = "bbbcccccaaaaazxc";
    printf("length = %d\n",lengthOfLongestSubstring(s));

    return 0;
}